/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package my.simpleinsulinpump;
import Akanksha.Alarm;
import javax.swing.JLabel;
import javax.swing.Timer;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Date;
/**
 *
 * @author arianareyessantiago
 */
public class BatteryLabel extends JLabel implements ActionListener {
    public static double batteryLife = 100;
    public BatteryLabel(){
        
        super("" + new Date());
        Timer t = new Timer(60000, this);
        t.start();
    } 
      public void actionPerformed(ActionEvent ae) {
        
        batteryLife = batteryLife - 1;
        System.out.println(batteryLife);
        setText(Double.toString(batteryLife)+"%");
        Alarm alarm = new Alarm();
        if(batteryLife <= 15){
            alarm.setAlarm("You currently have 15% or less of your Battery Left!. Change Batteries");
                if(batteryLife <=8){
                   alarm.setAlarm("You currently have 8% or less of your Battery Left!. You are now going into Battery Reserve"); 
                   if(batteryLife <= 3){
                       alarm.play();
                   }
            }
        }
        
        
        
  }
}
